package chai.ningning.address;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 结论: InetAddress实例 表示 IP地址
 */
public class InetAddressTest3 {

    public static void main(String[] args) throws UnknownHostException {

        // 使用 byte 数组指定一个 "地址"
        byte[] address = {(byte) 192, (byte) 165,1,11};

        // 通过 InetAddress 类的 类方法 根据 指定的 字节数组 获得 一个 InetAddress 实例
        InetAddress inetAddress = InetAddress.getByAddress(address);
        System.out.println(inetAddress);

        address = new byte[]{1,0,0,58};
        inetAddress = InetAddress.getByAddress(address);
        System.out.println(inetAddress);

        inetAddress = InetAddress.getByName("DESKTOP-QUF3J7K");
        System.out.println(inetAddress);

        inetAddress = InetAddress.getByName("1.0.0.30");
        System.out.println(inetAddress);
    }
}
